From 895f54119246bb010ad2030abdfa6bd008a1aebb Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Sun, 20 Jul 2014 17:02:09 -0700 Subject: [PATCH] Add regression test for running `cargo test` twice --- tests/support/mod.rs | 14 ++++++++++++++ tests/test_cargo_test.rs | 24 ++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 227ccf2e7..ca94f5088 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -413,6 +413,20 @@ pub fn basic_bin_manifest(name: &str) -> String { "#, name, name) } +pub fn basic_lib_manifest(name: &str) -> String { + format!(r#" + [package] + + name = "{}" + version = "0.5.0" + authors = ["wycats@example.com"] + + [[lib]] + + name = "{}" + "#, name, name) +} + pub static RUNNING: &'static str = " Running"; pub static COMPILING: &'static str = " Compiling"; pub static FRESH: &'static str = " Fresh"; diff --git a/tests/test_cargo_test.rs b/tests/test_cargo_test.rs index 17c551345..edb30052a 100644 --- a/tests/test_cargo_test.rs +++ b/tests/test_cargo_test.rs @@ -1,7 +1,7 @@ use std::str; -use support::{project, execs, basic_bin_manifest, COMPILING, cargo_dir}; -use support::{ResultTest}; +use support::{project, execs, basic_bin_manifest, basic_lib_manifest}; +use support::{COMPILING, cargo_dir, ResultTest}; use hamcrest::{assert_that, existing_file}; use cargo::util::process; @@ -284,3 +284,23 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured\n\n\ compiling = COMPILING, dir = p.root().display()).as_slice())); }) + +// Regression test for running cargo-test twice with +// tests in an rlib +test!(cargo_test_twice { + let p = project("test_twice") + .file("Cargo.toml", basic_lib_manifest("test_twice").as_slice()) + .file("src/test_twice.rs", r#" + #![crate_type = "rlib"] + + #[test] + fn dummy_test() { } + "#); + + p.cargo_process("cargo-build"); + + for _ in range(0u, 2) { + assert_that(p.process(cargo_dir().join("cargo-test")), + execs().with_status(0)); + } +}) -- 2.30.2